package com.huixh.train.business.enums;

import java.math.BigDecimal;

/**
 * @author huixh
 */
public enum TrainTypeEnum {
    /**
     * 车辆类型
     */
    G("G", "高铁", new BigDecimal("1.6")),
    D("D", "动车", new BigDecimal("1.4")),
    T("T", "特快", new BigDecimal("1.2")),
    K("K", "快速", new BigDecimal("0.8")),
    Z("Z", "直达", new BigDecimal("0.8")),
    C("C", "城际", new BigDecimal("0.6")),
    S("S", "普通", new BigDecimal("0.4")),
    Y("Y", "普通", new BigDecimal("0.4")),

    M("M", "动车组", new BigDecimal("0.6")),

    F("F", "动车组", new BigDecimal("0.6")),

    L("L", "临时旅客列车", new BigDecimal("0.6")),


    ;
    private String code;

    private String desc;
    /**
     * 票价比例
     */
    private BigDecimal price;

    TrainTypeEnum(String code, String desc, BigDecimal price) {
        this.code = code;
        this.desc = desc;
        this.price = price;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static BigDecimal getPrice(String code) {
        for (TrainTypeEnum trainTypeEnum : TrainTypeEnum.values()) {
            if (trainTypeEnum.getCode().equals(code)) {
                return trainTypeEnum.getPrice();
            }
        }
        return new BigDecimal("0");
    }

    @Override
    public String toString() {
        return "TrainTypeEnum{" +
                "code='" + code + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}
